package org.example.week10;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.*;

import java.io.IOException;


@WebServlet("/submit-register")
public class RegisterServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
        
        UserDAO userDAO = new UserDAO();
        String username = request.getParameter("username");
        int password = Integer.parseInt(request.getParameter("password"));
        
        userDAO.addUser(new User(0, username, password, 3));
        response.sendRedirect("index.jsp");
    }
}